var newTime = timeAll();
// 本类的项目
function ajaxtest() {
    var timeStamp = "timeStamp:" + newTime + 'BM' + "productCategoryId:" + '01' + 'BM';
    var signs = md5(timeStamp);
    signs = signs.toUpperCase();

    $.ajax({
        type: "post",
        url: webUrl + "orderProcessing/brand",
        data: {
            "timeStamp": newTime,
            "productCategoryId": '01',
            "sign": signs,
        },
        dataType: "JSON",
        async: false,
        success: function (data) {
            $("#list").html(data)
            if (data.status == 200) {
                var str;
                for (var i = 0; i < data.data.length; i++) {
                    str = '<ul class="left-item">' + '<li onclick=ss(\"' + data.data[i].id + '\")>' + data.data[i].brandNameChn +
                        '</li>' + '</ul>';
                    $("#tab").append(str);
                    var ls = document.getElementById("tab").getElementsByTagName("li");
                    ls[0].className = "selected"
                    textTab();
                    ss(data.data[0].id)
                }
            } else if (data.status == 300) {
                document.location.href = '../login/login.html';
            } else if (data.status == 500) {
                dialog(data.msg);
            }
        }
    });
}

function textTab() {
    //获取index下标
    var $tab_li = $('#tab ul li');
    // 初始化index
    var index = $tab_li.index(0)
    $tab_li.click(
        function () {
            $tab_li.removeClass('selected')
            $(this).addClass('selected').siblings().removeClass('selected');
            index = $tab_li.index(this);
            $('html,body').animate({scrollTop: '0px'}, 800);
        }
    );
}

window.onload = function () {
    var h = document.documentElement.clientHeight - 67;//可见区域高度
    ffff = document.getElementById('tab');
    ffff.style.height = h + "px";

    var rightH = document.documentElement.clientHeight - 67;//可见区域高度
    rightss = document.getElementById('brandList');
    rightss.style.height = rightH + "px";
}


function ss(id) {
    var timeStamp = "timeStamp:" + newTime + 'BM' + "brandId:" + id + "BM";
    var signs = md5(timeStamp);
    signs = signs.toUpperCase();

    $.ajax({
        type: "post",
        url: webUrl + "orderProcessing/phone/list",
        data: {
            "timeStamp": newTime,
            "brandId": id,
            "sign": signs,
        },
        dataType: "JSON",
        async: false,
        success: function (data) {
            $("#brandList").html(data);
            if (data.status == 200) {
                var listStr;
                var imgStr;
                var j = 3;
                for (var i = 0; i < data.data.length; i++) {
                    var idIndexdsss = data.data[i].id;
                    var namessss = data.data[i].productNameChn;
                    namessss = namessss.replace(/\s/ig, '');
                    listStr = '<div class="Right-item" onclick=typeClick(\"' + idIndexdsss + '\",\"' + namessss + '\")>';
                    if (i == 0) {
                        imgStr = '<div class="text-img" style="background: #32dac3">' + 1 +
                            '</div>';
                    } else if (i == 1) {
                        imgStr = '<div class="text-img" style="background: #32daa9">' + 2 +
                            '</div>';
                    } else if (i == 2) {
                        imgStr = '<div class="text-img" style="background: #32d97a">' + 3 +
                            '</div>';
                    } else {
                        j = j + 1;
                        imgStr = '<div class="text-img">' + j +
                            '</div>';
                    }
                    listStr = listStr + imgStr + '<div>' + data.data[i].productNameChn +
                        '</div>' +
                        '</div>';
                    $('#brandList').append(listStr)
                }
            } else if (data.status == 300) {
                document.location.href = '../../html/login.html';
            }
        },
        error: function (data) {
            //弹出报错内容　　
            dialog("服务器异常")
        }
    });
}


function typeClick(id, indexName) {
    document.location.href = '../addNewOrder/addNewOrder.html?strArray=' + id;
}


// 搜索手机型号
function searchshoper() {
    document.location.href = 'typeSearvh/typeSearvh.html' + strArray;
}




